#ifndef GUI_CAMERA_H_H_H_H_
#define GUI_CAMERA_H_H_H_H_
#include "view3DInventorViewer.h"
namespace Gui
{
class CameraRoot
{
public:

	CameraRoot(void);
	virtual ~CameraRoot(void);
public:

	virtual void mouseDown(QMouseEvent* e){}
	virtual void mouseMove(QMouseEvent* e){}
	virtual void mouseUp(QMouseEvent* e){}

	virtual void keydown(QKeyEvent* e){}
	virtual void keyup(QKeyEvent* e){}

	virtual void keydown(CKDWORD key){}
	virtual void keyup(CKDWORD key){}

	virtual void wkeydwon(){}
	virtual void wkeyup(){}


	void update();
	virtual void rotateCamera();
	void moveCamera();


public:


public:
	CKInputManager* mInputManager;
	CKTimeManager*  mTimeManager;
	CKCamera*       _camera;
	bool           mIsButtonDown;  
    float rx,ry,tx,tz,ang;
	

	QPoint   offset;

protected:

	VxVector mDirection;
	float    mMove,mRotate;
	float    mXRotate,mYRotate;

	bool wButtonDown,sButtonDown,aButtonDown,dButtonDown;
};

class FreeCamera : public CameraRoot
{
public:

	FreeCamera(const char* cameraName);
public:

    void mouseDown(QMouseEvent* e);
	void mouseMove(QMouseEvent* e);
	void mouseUp(QMouseEvent* e);

	void keydown(QKeyEvent* e);
	void keyup(QKeyEvent* e);

	void keydown(CKDWORD key);
	void keyup(CKDWORD key);

	 void wkeydwon();
	 void wkeyup();

	 void rotateCameraByAxis(const VxVector&,float ang,CKCamera*);

	 void rotateCamera();

private:

		VxVector ori_dir,ori_up,ori_right;
};

class OribitCamera : public CameraRoot
{
public:
	OribitCamera(const char* cn);

public:

	void mouseDown(QMouseEvent* e);
	void mouseMove(QMouseEvent* e);
	void mouseUp(QMouseEvent* e);

	void keydown(QKeyEvent* e);
	void keyup(QKeyEvent* e);

	void keydown(CKDWORD key){}
	void keyup(CKDWORD key){}

	 void wkeydwon(){}
	 void wkeyup(){}


};

class CameraManager
{
public:
	CameraManager();
	~CameraManager();
public:
	static CameraManager* _instance;
	static CameraManager* Instance();

public:
	void addCamera(CameraRoot* ca);

	void mousebuttonDown(QMouseEvent* e);
	void mousebuttonUp(QMouseEvent* e);
	void mousebuttonMove(QMouseEvent* e);

	void keydown(CKDWORD key);
	void keyup(CKDWORD key);

	void wkeydown();
	void wkeyup();


	void keydown(QKeyEvent* e);
	void keyup(QKeyEvent* e);

	void setActiveCamera(CameraRoot* ca);

	void updateCamera();

private:
    CameraRoot*                  activeCamera;
	std::vector<CameraRoot*>::iterator _cameraItor;
	std::vector<CameraRoot*> _cameraList;

};

}

#endif